<div class="data-table table-striped">
        <form class="ids">
            <table>
                <thead>
                    <tr>
                        <th>ID</th>
                        <th>主品牌名称</th>
                        <th>主品牌国家</th>
                        <th>主品牌首字母</th>
                        <th>主品牌全拼</th>
                        <th>状态</th>
                        <th style="width:200px;text-align:center;">操作</th>
                    </tr>
                </thead>
                <tbody id="trlist">
                    <php>foreach($list AS $val):</php>
                    <tr>
                        <td>{$val.mbrand_id}</td>
                        <td>{$val.name}</td>
                        <td>{$val.country}</td>
                        <td>{$val.first_char}</td>
                        <td>{$val.spell}</td>
                        <td id="status_cn{$val.mbrand_id}"><if condition="$val[status] eq 0">启用<else/>禁用</if></td>
                        <td style="width:200px;text-align:center;">
                            <if condition="$can_manage">
                                <php> if($val['status']>-1):</php>
                                    <a title="编辑" href="javascript:edit('{$val.mbrand_id}');">编辑</a>  &nbsp;
                                    <if condition="$val['status'] gt 0">
                                        <a id="status{$val.mbrand_id}" href="javascript:toggle('{$val.mbrand_id}');">启用</a>  &nbsp;
                                    <else/>
                                        <a id="status{$val.mbrand_id}" href="javascript:toggle('{$val.mbrand_id}');">禁用</a>  &nbsp;
                                    </if>

                                    <!--<a class="confirm ajax-get" href="javascript:del('{$val.mbrand_id}');">删除</a>-->
                                <php>endif;</php>
                            </if>
                        </td>
                    </tr>
                    <php>endforeach;</php>
                </tbody>
            </table>
        </form>
</div>
<div class="pageFaye"><div class="pager">{$page}</div> <div class="clear"></div></div>
<input type="hidden" name="p" value="{$p}">
<input type="hidden" name="char" value="{$curr_char}">
<input type="hidden" name="old_name_master" value="">
<input type="hidden" name="mbrand_id" value="">
<script>
    function toggle(id){
        var type = 1;
        if($('#status'+id).html()=='禁用'){
            type = 1;
        }else{
            type = 0;
        }
        $.post("/CarModel/toggle/",{'id':id,'table':'mbrand','type':type}, function (data) {
            if(data.code=='200'){
                if($('#status'+id).html()=='禁用'){
                    $('#status'+id).html('启用')
                    $('#status_cn'+id).html('禁用')
                }else{
                    $('#status'+id).html('禁用')
                    $('#status_cn'+id).html('启用')
                }
            }else{
                shibai_alert(data.msg)
            }
        }, "json");
    }
    function edit(id){
        $(".master_brand_alert").eq(0).fadeIn();
        $(".yunBei").show();
        //
        $.get("/CarModel/base_info/",{'id':id,'type':'mbrand'}, function (data) {
            $('input[name=mbrand_id]').val(id)
            $('input[name=old_name_master]').val(data.data.name)
            $('input[name=name_master]').val(data.data.name);
            $('input[name=spell_master]').val(data.data.spell);
            $('select[name=country_master]').val(data.data.country);
            $('#status_master').val(data.data.status);
            $('select[name=first_char_master]').val(data.data.first_char);
        },'json')
    }
    function del(id){
        confirm_alert('<div style="color:red">确认移除该品牌？</div>', confirm);
        function confirm() {
            $('.determine').click(function () {
                colse_hide();
                remove(id);
            });
        }
    }

    function remove(id){
        $.post("/CarModel/remove/",{'id':id,'type':'mbrand'}, function (data) {
            if(data.code=='200'){
                var curr_char = $('input[name=char]').val();
                btn_alert(data.msg,2,function(){
                    $(".fchar").each(function (i) {
                        if ($(this).text().trim() == curr_char) {
                            $(this).click();
                        }
                    });
                });
            }else{
                shibai_alert(data.msg);
            }
        }, "json");
    }


</script>